const Mock = require('mockjs')

const List = []
const paymentList = []
const count = 5

for (let i = 0; i < count; i++) {
    List.push(Mock.mock({
        id: '@increment',
        created_time: '@now',
        account: '23423*****43243',
        name: '罗**',
        'status|1': [0, 1, 2],
        'price|1': [10.00, 20.00, 30.00]
    }))
    paymentList.push(Mock.mock({
        id: '@increment',
        created_time: '@now',
        account: '23423*****43243',
        name: '罗**',
        province: '@csentence(2, 3)',
        city: '@csentence(2, 2)',
        area: '@csentence(3, 5)',
        path: '@csentence(3, 5)',
        bank: '@csentence(5, 10)',
        'status|1': [0, 1, 2]
    }))
}

module.exports = [
    {
        url: '/vue-element-admin/pay/assets',
        type: 'get',
        response: config => {
            const { page = 1, limit = 20 } = config.query
            const mockList = List
            const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
            return {
                code: 20000,
                data: {
                    total: mockList.length,
                    items: pageList
                }
            }
        }
    },
    {
        url: '/vue-element-admin/pay/payment',
        type: 'get',
        response: config => {
            const { page = 1, limit = 20 } = config.query
            const mockList = paymentList
            const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
            return {
                code: 20000,
                data: {
                    total: mockList.length,
                    items: pageList
                }
            }
        }
    },
    {
        url: '/vue-element-admin/assets/create',
        type: 'post',
        response: config => {
            const { price, payment_id } = config.query
            return {
                code: 20000,
                data: {
                    id: '@increment',
                    created_time: '@now',
                    account: '23423*****43243',
                    name: '罗**',
                    status: 0,
                    price,
                    payment_id
                }
            }
        }
    },
    {
        url: '/vue-element-admin/payment/update',
        type: 'post',
        response: () => {
            return {
                code: 20000,
                data: 'success'
            }
        }
    },
    {
        url: '/vue-element-admin/payment/delete',
        type: 'post',
        response: () => {
            return {
                code: 20000,
                data: 'success'
            }
        }
    },
    {
        url: '/vue-element-admin/payment/create',
        type: 'post',
        response: () => {
            return {
                code: 20000,
                data: 'success'
            }
        }
    }
]

